package solution;

/**
 * @author : wenchao.long
 * @date : Created in 2024-07-03 下午 10:49 周三
 * @description :
 * 		<a href="https://leetcode.cn/problems/harshad-number/description/">哈沙德数</a>
 */
public class No3099 {

	public static int sumOfTheDigitsOfHarshadNumber(int x) {
		String s = String.valueOf(x);
		int sum = 0;
		for (int i = 0; i < s.length(); i++) {
			sum += s.charAt(i) - '0';
		}
		return x % sum == 0 ? sum : -1;
	}

	public static void main(String[] args) {
		System.out.println(sumOfTheDigitsOfHarshadNumber(23));
	}
}
